
{extend name="common/form" /}
{block name="form" /}
<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
    <div class="widget am-cf">
        <div class="widget-head am-cf">
            <div class="widget-title am-fl">添加用户</div>
        </div>
        <div class="widget-body am-fr">
            <form class="am-form tpl-form-border-form tpl-form-border-br">
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        昵称                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="nickname" value="{$info.nickname|default=''}" required="required" class="tpl-form-input" placeholder="请填写昵称">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        手机号码                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="telephone" value="{present name='$info.telephone'}{$info.telephone}{/present}" required="required" class="tpl-form-input" placeholder="请填写手机号码">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        邮箱                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="email" value="{present name='$info.email'}{$info.email}{/present}" required="required" class="tpl-form-input" placeholder="请填写邮箱">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        登录密码                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="password" value="{present name='$info.password'}{$info.password}{/present}" required="required" class="tpl-form-input" placeholder="请填写登录密码">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        确认登录密码
                    </label>
                    <div class="am-u-sm-9">
                        <input type="password" name="to_password" value="{present name='$info.password'}{$info.password}{/present}" required="required" class="tpl-form-input" placeholder="请填写登录密码">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        性别
                    </label>
                    <div class="am-u-sm-9">
                        <label class="am-radio am-align-left">
                            <input type="radio" name="sex" value="男" data-am-ucheck {present name='$info.sex'}{eq name='$info.sex' value="男"}checked{/eq}{else/}checked{/present}>男
                        </label>
                        <label class="am-radio am-align-left">
                            <input type="radio" name="sex" value="女" {present name='$info.sex'}{eq name='$info.sex' value="女"}checked{/eq}{/present} data-am-ucheck>女
                        </label>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        代理等级
                    </label>
                    <div class="am-u-sm-9">
                        <select name="agent_grade">
                            {foreach $agent as $v}
                                    <option value="{$v.id}" {present name='$info.agent_grade'}{eq name="$info.agent_grade" value="$v.id"}selected{/present}>{$v.name}</option>
                            {/foreach}
                        </select>

                    </div>
                </div>

                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        账户余额
                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="commission" value="{present name='$info.commission'}{$info.commission}{/present}" required="required" class="tpl-form-input" placeholder="请填写账户余额">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        真实姓名                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="true_name" value="{present name='$info.true_name'}{$info.true_name}{/present}" required="required" class="tpl-form-input" placeholder="请填写真实姓名">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        身份证号                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="IDCard" value="{present name='$info.IDCard'}{$info.IDCard}{/present}" required="required" class="tpl-form-input" placeholder="请填写身份证号">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        支付宝账号                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="alipay" value="{present name='$info.alipay'}{$info.alipay}{/present}" required="required" class="tpl-form-input" placeholder="请填写支付宝账号">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                       所属运营中心
                    </label>
                    <div class="am-u-sm-9" id="yunyin">
                        <select name="operate_id" data-type="type_1" type="1" onchange="getNext(this)" required="required">
                            {foreach $operate as $v}
                            <option  value="{$v.id}" {notempty name='$info.operate_id'}{eq name='$info.operate_id' value="$v.id"}selected{/eq}{/notempty}> {$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        注册地址                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="address" value="{present name='$info.address'}{$info.address}{/present}" required="required" class="tpl-form-input" placeholder="请填写注册地址">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        是否是业务员                    </label>
                    <div class="am-u-sm-9">
                        <div class="tpl-switch">
                            <input type="checkbox" name="is_salesman"  class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs" {present name='$info.is_salesman'}{eq name='$info.is_salesman' value="1"}checked{/eq} {/present}>
                            <div class="tpl-switch-btn-view">
                                <div></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        上级手机号
                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="parent_id" value="{present name='$info.parent_id'}{$info.parent_id}{/present}" class="tpl-form-input" placeholder="请填写上级手机号">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        联通工号                    </label>
                    <div class="am-u-sm-9">
                        <input type="text" name="number" value="{present name='$info.number'}{$info.number}{/present}" required="required" class="tpl-form-input" placeholder="请填写联通工号">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        状态
                    </label>
                    <div class="am-u-sm-9">
                        <div class="tpl-switch">
                            <input type="checkbox" name="lock"  class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs" {present name='$info.lock'}{eq name='$info.lock' value="1"}checked{/eq} {else}checked{/present}>
                            <div class="tpl-switch-btn-view">
                                <div></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-form-group">
                    <div class="am-u-sm-9 am-u-sm-push-3">
                        <button type="button" onclick="add('{:url($type)}','form')" class="am-btn am-btn-primary tpl-btn-bg-color-success" >
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name='script'}
<script type="text/javascript">
    function getNext(dom) {
        var id = parseInt($(dom).attr('type'));
        var nextDom = $('select[data-type="type_'+(id+1)+'"]');
        if(dom.value ==0){
            nextDom.next('br').remove();
            nextDom.remove();
        }
        $.get("{:url('operate/getNextOperate')}",{id:dom.value},function (result) {
            var htm= '';
            if(result.length ==0){
                nextDom.next('br').remove();
                nextDom.remove();
                return;
            }
            for(var i=0;i<result.length;i++){
                htm+='<option value="'+result[i].id+'">'+result[i].name+'</option>'
            }
            if(nextDom.get(0) ==undefined){
                htm = "<select style='margin-top: 10px;' name='parent_id' data-type='type_"+(id+1)+"' type='"+(id+1)+"'  onchange=\"getNext(this)\">"+htm+"</select>"
                $('#yunyin').append(htm)
            }else{
                nextDom.html(htm)
            }
        },'json')
    }
</script>
{/block}
{extend}
